package Day005_API02.ZuoYe;

import java.math.BigDecimal;

public class Test2 {
    public static void main(String[] args) {

        Student s1 = new Student("张三","男",20,79.5);
        Student s2 = new Student("李四","女",21,80.2);
        Student s3 = new Student("王五","男",22,77.9);
        Student s4 = new Student("周六","男",20,55.8);
        Student s5 = new Student("赵七","女",21,99.9);

        BigDecimal b1 = new BigDecimal(s1.getFenshu());
        BigDecimal b2 = new BigDecimal(s2.getFenshu());
        BigDecimal b3 = new BigDecimal(s3.getFenshu());
        BigDecimal b4 = new BigDecimal(s4.getFenshu());
        BigDecimal b5 = new BigDecimal(s5.getFenshu());

        BigDecimal sum = b1.add(b2).add(b3).add(b4).add(b5);
        BigDecimal b = new BigDecimal(5);
        BigDecimal avg = sum.divide(b,2,BigDecimal.ROUND_HALF_UP);
        System.out.println("平均分:" + avg); // 78.66

    }
}

class Student {
    private String name;
    private String sex;
    private int age;
    private double fenshu;

    public Student() {
    }

    public Student(String name, String sex, int age, double fenshu) {
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.fenshu = fenshu;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getFenshu() {
        return fenshu;
    }

    public void setFenshu(double fenshu) {
        this.fenshu = fenshu;
    }
}
